package com.cjh.service;

import java.io.IOException;
import java.util.Map;
import java.util.Map.Entry;

import com.cjh.entity.HtmlPage;
import com.dajiangtai.djt_spider.util.HbaseUtil;
import com.dajiangtai.djt_spider.util.RedisUtil;

public class HbaseStoreService {
	private HbaseUtil hbaseUtil = new HbaseUtil();
	private RedisUtil redisUtil=new RedisUtil();
	private static final String TABLE_NAME = "tvcount";
	private static final String CF = "tvinfo";

	public void store(HtmlPage page) {
		Map<String, String> datas = page.getDatas();
		String rowkey = datas.get("rowkey");
		redisUtil.add("solr_youku.tvid", rowkey);
//		System.out.println("rowkey:::"+rowkey);
//		System.out.println("url:::"+page.getUrl());
//		System.out.println("datas:::"+page.getDatas());
//		datas.remove("rowkey");
		for (Entry<String, String> entry : datas.entrySet()) {
			try {
				hbaseUtil.put(TABLE_NAME, rowkey, CF, entry.getKey(), entry.getValue());
			} catch (IOException e) {

				e.printStackTrace();
			}
		}
	}

	public static void main(String[] args) {
//		HbaseUtil hbaseUtil = new HbaseUtil();
//		try {
//			hbaseUtil.put(TABLE_NAME, "abc", CF, "aaaa", "bbb");
//		} catch (IOException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
	}
}
